//
//  SwiftString.swift
//  SwiftTool
//
//  Created by 红沙尘 on 2018/11/30.
//  Copyright © 2018年 红沙尘. All rights reserved.
//

import Foundation
import UIKit

extension String {
    
    func safe(str: Any?) -> String {
        
        if str is String {
            if str as! String == "<null>" || str as! String == "null"{
                return ""
            }
            
            return str as! String
        }
        
        if str == nil {
            return ""
        }
        
        if str is NSNull {
            return ""
        }
        
        if str is NSNumber {
            return String(Int(truncating: str as! NSNumber))
        }
        
        return ""
    }
}
